#!/bin/bash
# ----------------------------------------------------------------------------
# Gets everything necessary started for /var/spool/packet/
# You should customize this!

# TODO: soundmodem

TNCMODE=net

pkill kissutil
pkill net2kiss
pkill kissattach
pkill direwolf

sudo ctlinnd reload newsfeeds now

case "$TNCMODE" in
    serial)
	echo Direct Serial TNC configuration
	kissutil >>/var/log/kissutil.out -T %H:%M:%S -p /dev/ttyUSB0 -s 1200 -f /var/spool/packet/send -o /var/spool/packet/recv &
	;;

    direwolf)
	echo Direwolf configuration
	/home/cjb/direwolf/build/src/direwolf -t 0 -p -c /home/cjb/direwolf-packet.conf 2>&1 &
	sleep 1
	kissutil -T %H:%M:%S -p /tmp/kisstnc -f /var/spool/packet/send -o /var/spool/packet/recv 2>&1 >>/var/log/kissutil.out &
	;;

    net)
	echo Configuring system for an existing networking setup
	kissattach -l -m 256 /dev/ttyUSB0 1 44.136.248.81
	PORT=`net2kiss -f -i ax0 /dev/ptmx|tail -1 &`
	echo "KISS interface via " $PORT
	kissutil -T %H:%M:%S >>/var/log/kissutil.out -p ${PORT} -f /var/spool/packet/send -o /var/spool/packet/recv &
	kissparms -p 1 -t 50; kissparms -p 1 -l 30; kissparms -p 1 -r 2; kissparms -p 1 -s 30
	;;

    sdr)
	echo Receive-only SDR setup
	rtm_fm ...
	;;
esac

#
#
#
